package com.rzht.framework.presenter;

import com.rzht.framework.base.RxObserver;
import com.rzht.framework.base.RxPresenter;
import com.rzht.framework.model.login.LoginModel;
import com.rzht.framework.model.login.User;
import com.rzht.framework.view.LoginView;

/**
 * Created by lk on 2017/7/26.
 */

public class LoginPresenter extends RxPresenter<LoginView> {

    public LoginPresenter(LoginView loginView) {
        attachView(loginView);
    }

    public void login() {
        LoginModel.getInstance().login(mView.getUserName(), mView.getPassword(), new RxObserver<User>(mView) {

            @Override
            public void onSuccess(User bean) {
                mView.loginSuccess(bean);
            }

            @Override
            public void onFailed(Throwable e) {
                super.onFailed(e);
                mView.loginFailed();
            }
        });
    }

}
